//Funcion decode, utilizada para extraer la distancia de colision a dureza obtenida
//por la funcion colision_en_?. El formato de la codificacion es :
//de una cifra de 4 digitos, los 2 primeros - 10 , es la dureza, y los 2 ultimos son
//la distancia a esa dureza. pej. 6812 = 68-10=58 color dureza / (6812/100=68*100=6800-6812 = 0012 distancia)
function decode(int dato)
begin
	return ( dato - ((dato/100)*100) );
end;


function gravedad_simple_x()
private colision_en_x;
begin

		if (father.v_x>0)
			colision_en_x=colision_x(fich_nivel,dur_nivel,father.alto,father.x+(father.ancho>>1),father.y,(father.x+16+father.v_x),C_DUR_SUELO);
		else
			colision_en_x=colision_x(fich_nivel,dur_nivel,father.alto,father.x-(father.ancho>>1),father.y,(father.x-16+father.v_x),C_DUR_SUELO);	
	    end;
	    
		If (colision_en_x>=0 && ((colision_en_x/100)-10)==C_DUR_SUELO)
		colision_en_x = decode(colision_en_x);end;
		
		If (colision_en_x>=0)
			if (father.v_x>0) father.x+= colision_en_x-1;end
			if (father.v_x<0) father.x-= colision_en_x-1;end
			father.v_x = 0;
		End;  
		
		return  colision_en_x;
end;

function gravedad_simple_y()
private colision_en_y;
begin

		colision_en_y=colision_y(fich_nivel,dur_nivel,father.alto,father.x,father.y,(father.y+father.v_y),0,1);
		
		If (colision_en_y>=0) //&& ((colision_en_y/100)-10)==C_DUR_SUELO)
		colision_en_y = decode(colision_en_y);end;
		
		If ((colision_en_y>=0 && father.v_y>=0)) //suelo
			father.v_y =0; 
			father.tierra = 1;
			father.y += colision_en_y;
			v_x --;
		Else
	 	   father.tierra = 0;
		End;                                 
		If (colision_en_y>=0 && father.v_y<0) //techo
			father.v_y =colision_en_y*(-1);
		End;
		
		return colision_en_y;
end; 